package com.volunteer.controller;

import com.volunteer.common.Result;
import com.volunteer.service.StatisticsService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 统计控制器
 */
@RestController
@RequestMapping("/api/statistics")
@RequiredArgsConstructor
public class StatisticsController {

    private final StatisticsService statisticsService;

    /**
     * 获取系统概览统计（管理员）
     */
    @GetMapping("/overview")
    @PreAuthorize("hasRole('ADMIN')")
    public Result<Map<String, Object>> getOverviewStatistics() {
        Map<String, Object> statistics = statisticsService.getOverviewStatistics();
        return Result.success(statistics);
    }

    /**
     * 获取用户个人统计数据
     */
    @GetMapping("/user/{userId}")
    public Result<Map<String, Object>> getUserStatistics(@PathVariable Long userId) {
        Map<String, Object> statistics = statisticsService.getUserStatistics(userId);
        return Result.success(statistics);
    }
}

